package swu.cx.myglidetest

import android.content.Context
import android.widget.ImageView
import java.lang.ref.SoftReference
import kotlin.properties.Delegates

class BitmapRequest(val context: Context) {
    lateinit var url:String
    lateinit var img:SoftReference<ImageView>
    lateinit var urlMd5:String
    var loadingResId by Delegates.notNull<Int>()
    fun loading(loadingResId:Int):BitmapRequest{
        this.loadingResId = loadingResId
        return this
    }
    fun load(url:String):BitmapRequest{
        this.url = url
        this.urlMd5 = Md5Util.getMd5Code(url).toString()
        return this
    }
    fun into(imageView: ImageView){
        this.img = SoftReference(imageView)
        imageView.tag = urlMd5
        RequestManager.getInstance().addBitmapRequest(this)
    }
}